#pragma once


#include <IXImage.h>
#include <IXImageDraw.h>
#include "XFrameImpl.h"

template <class I>
class CXImageImpl : public CXFrameImpl<I>
{
    typedef CXFrameImpl<I> superclass;

    BEGIN_DEF_SKIN_CLASS(CXImage, superclass, gs_strGuidXSkin)
        IMP_BASIC_INTF(IXImage,    0)
    END_DEF_SKIN_CLASS();

    IMPL_CONTROL_OBJ(CXImageImpl, superclass, _T("Image"));

public:
    CXImageImpl();
    virtual ~CXImageImpl();

public:
    // IXImage
    virtual HRESULT STDMETHODCALLTYPE   put_Image(IN LPCTSTR szXNC);
    virtual HRESULT STDMETHODCALLTYPE   put_Image(IN XIMAGE xImage);
    virtual HRESULT STDMETHODCALLTYPE   put_Icon(IN LPCTSTR szXNC, BOOL bBig);
    virtual HRESULT STDMETHODCALLTYPE   put_Icon(IN XICON xIcon, IN BOOL bDestroy);

    virtual HRESULT STDMETHODCALLTYPE   get_ImagePath(OUT BSTR* pszXNC);

    virtual void    STDMETHODCALLTYPE   put_DrawType(IN ImageDrawType type);

    virtual HRESULT STDMETHODCALLTYPE   put_DrawParams(IN ImageDrawParams* pParam);
    virtual HRESULT STDMETHODCALLTYPE   get_DrawParams(OUT ImageDrawParams* pParam);

    virtual HRESULT STDMETHODCALLTYPE   put_ImageIndex(IN INT nHIndex, IN INT nVIndex);
    virtual HRESULT STDMETHODCALLTYPE   get_ImageIndex(IN LPINT pnHIndex, IN LPINT pnVIndex);

    virtual HRESULT STDMETHODCALLTYPE   put_ImageSubCount(IN INT nHCount, IN INT nVCount);
    virtual HRESULT STDMETHODCALLTYPE   get_ImageSubCount(IN LPINT pnHCount, IN LPINT pnVCount);

    virtual HRESULT STDMETHODCALLTYPE   put_ImageAlphaMode(IN eImageAlphaMode nAlphaMode);
    virtual HRESULT STDMETHODCALLTYPE   get_ImageAlphaMode(OUT eImageAlphaMode* pnAlphaMode);

    virtual HRESULT STDMETHODCALLTYPE   put_ImageAlphaValue(IN BYTE byAlphaValue);
    virtual HRESULT STDMETHODCALLTYPE   get_ImageAlphaValue(OUT LPBYTE pbyAlphaValue);

    virtual HRESULT STDMETHODCALLTYPE   put_ImageTransparentColor(IN COLORREF clrTrans);
    virtual HRESULT STDMETHODCALLTYPE   get_ImageTransparentColor(OUT LPCOLORREF pclrTrans);

public:
    // IXFrame
    virtual void    STDMETHODCALLTYPE   GetAutoSize(OUT LPSIZE pAutoSize);
    virtual void    STDMETHODCALLTYPE   Draw(XCANVAS xCanvas, const RECT& rcDraw);

public:
    // IXBaseObj
    virtual void STDMETHODCALLTYPE   OnFinalRelease();

protected:
    // CXFrameImpl
    virtual void OnColorizeEnabled(BOOL bEnabled);
    virtual void OnColorized(int hue, int sat, int light);

protected:
    void    ReleaseData();
    BOOL    NeedImageDraw();

protected:
    XString         m_strImageXNC;
    IXImageDraw*    m_pImageDraw;
};


class CXImage : public CXImageImpl<IXImage>
{
};
